import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '@/pages/Index'
import Detail from '@/pages/Detail'
import DetailProduct from '@/components/detail/DetailProduct'
import DetailParam from '@/components/detail/DetailParam'
import DetailAftermarket from '@/components/detail/DetailAftermarket'
import Login from '@/pages/Login'
// 找回密码
import FindPassword from '@/pages/FindPassword'
import FindPasswordFirst from '@/components/find/FindPasswordFirst'
import FindPasswordSecond from '@/components/find/FindPasswordSecond'
import FindPasswordSuccess from '@/components/find/FindPasswordSuccess'
// 注册
import Register from '@/pages/Register'
import RegisterAccount from '@/components/register/RegisterAccount'
import RegisterAccountProtocol from '@/components/register/RegisterAccountProtocol'
import RegisterAccountSuccess from '@/components/register/RegisterAccountSuccess'
import RegisterAuthentication from '@/components/register/RegisterAuthentication'
// import RegisterPhone from '@/components/register/RegisterPhone'
import RegisterIdentity from '@/components/register/RegisterIdentity'
// import RegisterStudent from '@/components/register/RegisterStudent'
import RegisterEmergencyContact from '@/components/register/RegisterEmergencyContact'
import RegisterSuccess from '@/components/register/registerSuccess'
import Pay from '@/pages/Pay'
import PaySuccess from '@/components/pay/PaySuccess'
import Personal from '@/pages/Personal'
import PersonalMessage from '@/components/personal/message/PersonalMessage'
import PersonalMessageActivity from '@/components/personal/message/PersonalMessageActivity'
import PersonalMessageNotice from '@/components/personal/message/PersonalMessageNotice'
import PersonalOrder from '@/components/personal/order/PersonalOrder'
import PersonalOrderDetail from '@/components/personal/order/PersonalOrderDetail'
import PersonalOrderLogistics from '@/components/personal/order/PersonalOrderLogistics'
import PersonalOrderAfterSale from '@/components/personal/order/PersonalOrderAfterSale'
import PersonalOrderReturn from '@/components/personal/order/PersonalOrderReturn'
import PersonalOrderBarter from '@/components/personal/order/PersonalOrderBarter'
import PersonalBill from '@/components/personal/bill/PersonalBill'
import PersonalBillNotPay from '@/components/personal/bill/PersonalBillNotPay'
import PersonalBillHasPaid from '@/components/personal/bill/PersonalBillHasPaid'
import PersonalBillRepay from '@/components/personal/bill/PersonalBillRepay'
import PersonalBillDetail from '@/components/personal/bill/PersonalBillDetail'
import PersonalDiscount from '@/components/personal/discount/PersonalDiscount'
import PersonalDiscountNotUse from '@/components/personal/discount/PersonalDiscountNotUse'
import PersonalDiscountUsed from '@/components/personal/discount/PersonalDiscountUsed'
import PersonalDiscountExpire from '@/components/personal/discount/PersonalDiscountExpire'
import PersonalAccount from '@/components/personal/account/PersonalAccount'
import PersonalAccountSecurity from '@/components/personal/account/PersonalAccountSecurity'
import PersonalAccountProfile from '@/components/personal/account/PersonalAccountProfile'
import PersonalAccountContact from '@/components/personal/account/PersonalAccountContact'
import PersonalIdentity from '@/components/personal/identity/PersonalIdentity'
// import PersonalIdentityAuthentication from '@/components/personal/identity/PersonalIdentityAuthentication'
import PersonalIdentityEdit from '@/components/personal/identity/PersonalIdentityEdit'
import PersonalIdentityIdentity from '@/components/personal/identity/PersonalIdentityIdentity'
// import PersonalIdentityStudent from '@/components/personal/identity/PersonalIdentityStudent'
import PersonalIdentityContacts from '@/components/personal/identity/PersonalIdentityContacts'
import PersonalIdentitySuccess from '@/components/personal/identity/PersonalIdentitySuccess'
import PersonalAddress from '@/components/personal/address/PersonalAddress'
import PersonalQuota from '@/components/personal/PersonalQuota'
import Buy from '@/pages/Buy'
import BuyConsentProtocol from '@/components/buy/BuyConsentProtocol'
import Search from '@/pages/Search'
import Help from '@/pages/Help'
import Activity from '@/pages/Activity'
import Whiteday from '@/components/activity/Whiteday'
import NotFound from '@/pages/404'
// const PersonalQuota = () => import('@/components/personal/PersonalQuota')
// const NotFound = () => import('@/pages/404')
// const Help = () => import('@/pages/Help')
// const FindPassword = () => import('@/pages/FindPassword')
// const PersonalDiscount = () => import('@/components/personal/discount/PersonalDiscount')
// const PersonalDiscountNotUse = () => import('@/components/personal/discount/PersonalDiscountNotUse')
// const PersonalDiscountUsed = () => import('@/components/personal/discount/PersonalDiscountUsed')
// const PersonalDiscountExpire = () => import('@/components/personal/discount/PersonalDiscountExpire')
Vue.use(VueRouter)

export default new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Index',
      component: Index,
      meta: {
        showPageHeader: true,
        showPageFooter: true
      }
    },
    {
      path: '/login',
      name: 'Login',
      component: Login,
      meta: {
        showPageHeader: false,
        showPageFooter: false
      }
    },
    {
      path: '/find',
      name: 'FindPassword',
      component: FindPassword,
      redirect: '/find/first',
      children: [
        {
          path: 'first',
          name: 'FindPasswordFirst',
          component: FindPasswordFirst,
          meta: {
            showPageHeader: false,
            showPageFooter: false
          }
        },
        {
          path: 'second',
          name: 'FindPasswordSecond',
          component: FindPasswordSecond,
          meta: {
            showPageHeader: false,
            showPageFooter: false
          }
        },
        {
          path: 'success',
          name: 'FindPasswordSuccess',
          component: FindPasswordSuccess,
          meta: {
            showPageHeader: false,
            showPageFooter: false
          }
        }
      ]
    },
    {
      path: '/register',
      name: 'Register',
      component: Register,
      redirect: '/register/account',
      children: [
        {
          path: 'account',
          name: 'RegisterAccount',
          component: RegisterAccount,
          meta: {
            showPageHeader: false,
            showPageFooter: false
          }
        },
        {
          path: 'protocol',
          name: 'RegisterAccountProtocol',
          component: RegisterAccountProtocol,
          meta: {
            showPageHeader: false,
            showPageFooter: false
          }
        },
        {
          path: 'account/success',
          name: 'RegisterAccountSuccess',
          component: RegisterAccountSuccess,
          meta: {
            showPageHeader: false,
            showPageFooter: false
          }
        },
        {
          path: 'authentication',
          component: RegisterAuthentication,
          redirect: '/register/authentication/identity',
          children: [
            {
              path: 'identity',
              name: 'RegisterIdentity',
              component: RegisterIdentity,
              meta: {
                showPageHeader: false,
                showPageFooter: false,
                step: 1
              }
            },
            {
              path: 'emergency',
              name: 'RegisterEmergencyContact',
              component: RegisterEmergencyContact,
              meta: {
                showPageHeader: false,
                showPageFooter: false,
                step: 2
              }
            },
            {
              path: 'success',
              name: 'RegisterSuccess',
              component: RegisterSuccess,
              meta: {
                showPageHeader: false,
                showPageFooter: false,
                step: 3
              }
            }
          ]
        }
        // {
        //   path: 'phone',
        //   name: 'RegisterPhone',
        //   component: RegisterPhone,
        //   meta: {
        //     showPageHeader: false,
        //     showPageFooter: false,
        //     step: 2
        //   }
        // },
        // {
        //   path: 'student',
        //   name: 'RegisterStudent',
        //   component: RegisterStudent,
        //   meta: {
        //     showPageHeader: false,
        //     showPageFooter: false,
        //     step: 3
        //   }
        // },
      ]
    },
    {
      path: '/detail',
      name: 'Detail',
      component: Detail,
      redirect: 'detail/product',
      children: [
        {
          path: 'product',
          name: 'DetailProduct',
          component: DetailProduct,
          meta: {
            showPageHeader: true,
            showPageFooter: true
          }
        },
        {
          path: 'param',
          name: 'DetailParam',
          component: DetailParam,
          meta: {
            showPageHeader: true,
            showPageFooter: true
          }
        },
        {
          path: 'aftermarket',
          name: 'DetailAftermarket',
          component: DetailAftermarket,
          meta: {
            showPageHeader: true,
            showPageFooter: true
          }
        }
      ]
    },
    {
      path: '/pay',
      name: 'Pay',
      component: Pay,
      meta: {
        requireAuth: true,
        showPageHeader: false,
        showPageFooter: true
      }
    },
    {
      path: '/pay/success',
      name: 'PaySuccess',
      component: PaySuccess,
      meta: {
        showPageHeader: false,
        showPageFooter: true
      }
    },
    {
      path: '/personal',
      name: 'Personal',
      component: Personal,
      redirect: '/personal/message',
      meta: {
        breadcrumbName: 'personalCenter'
      },
      children: [
        {
          path: 'message',
          name: 'PersonalMessage',
          component: PersonalMessage,
          redirect: 'message/activity',
          meta: {
            breadcrumbName: 'messageCenter'
          },
          children: [
            {
              path: 'activity',
              name: 'PersonalMessageActivity',
              component: PersonalMessageActivity,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            },
            {
              path: 'notice',
              name: 'PersonalMessageNotice',
              component: PersonalMessageNotice,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            }
          ]
        },
        {
          path: 'order/:type/:page',
          name: 'PersonalOrder',
          component: PersonalOrder,
          props: true,
          meta: {
            requireAuth: true,
            showPageHeader: false,
            showPageFooter: true,
            breadcrumbName: 'myOrder'
          }
        },
        {
          path: 'bill',
          component: PersonalBill,
          redirect: 'bill/notPay',
          meta: {
            breadcrumbName: 'myBill'
          },
          children: [
            {
              path: 'notPay',
              name: 'PersonalBillNotPay',
              component: PersonalBillNotPay,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            },
            {
              path: 'hasPaid',
              name: 'PersonalBillHasPaid',
              component: PersonalBillHasPaid,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            }
          ]
        },
        {
          path: 'bill/detail',
          name: 'PersonalBillDetail',
          component: PersonalBillDetail,
          meta: {
            requireAuth: true,
            showPageHeader: false,
            showPageFooter: true,
            breadcrumbName: 'myBill'
          }
        },
        {
          path: 'discount',
          name: 'PersonalDiscount',
          component: PersonalDiscount,
          redirect: 'discount/notUse',
          meta: {
            breadcrumbName: 'myDiscount'
          },
          children: [
            {
              path: 'notUse',
              name: 'PersonalDiscountNotUse',
              component: PersonalDiscountNotUse,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            },
            {
              path: 'used',
              name: 'PersonalDiscountUsed',
              component: PersonalDiscountUsed,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            },
            {
              path: 'expire',
              name: 'PersonalDiscountExpire',
              component: PersonalDiscountExpire,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            }
          ]
        },
        {
          path: 'account',
          name: 'PersonalAccount',
          component: PersonalAccount,
          redirect: 'account/security',
          meta: {
            breadcrumbName: 'accountSettings'
          },
          children: [
            {
              path: 'security',
              name: 'PersonalAccountSecurity',
              component: PersonalAccountSecurity,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            },
            {
              path: 'profile',
              name: 'PersonalAccountProfile',
              component: PersonalAccountProfile,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            },
            {
              path: 'contact',
              name: 'PersonalAccountContact',
              component: PersonalAccountContact,
              meta: {
                requireAuth: true,
                showPageHeader: false,
                showPageFooter: true
              }
            }
          ]
        },
        {
          path: 'identity',
          name: 'PersonalIdentity',
          component: PersonalIdentity,
          meta: {
            requireAuth: true,
            showPageHeader: false,
            showPageFooter: true,
            breadcrumbName: 'identityAuthentication'
          }
        },
        {
          path: 'address',
          name: 'PersonalAddress',
          component: PersonalAddress,
          meta: {
            requireAuth: true,
            showPageHeader: false,
            showPageFooter: true,
            breadcrumbName: 'address'
          }
        }
      ]
    },
    {
      path: '/personal/order/detail',
      name: 'PersonalOrderDetail',
      component: PersonalOrderDetail,
      meta: {
        showPageHeader: false,
        showPageFooter: true,
        requireAuth: true
      }
    },
    {
      path: '/personal/order/logistics',
      name: 'PersonalOrderLogistics',
      component: PersonalOrderLogistics,
      meta: {
        requireAuth: true,
        showPageHeader: false,
        showPageFooter: true
      }
    },
    {
      path: '/personal/order/afterSale',
      name: 'PersonalOrderAfterSale',
      component: PersonalOrderAfterSale,
      meta: {
        requireAuth: true,
        showPageHeader: false,
        showPageFooter: true
      }
    },
    {
      path: '/personal/order/return',
      name: 'PersonalOrderReturn',
      component: PersonalOrderReturn,
      meta: {
        requireAuth: true,
        showPageHeader: false,
        showPageFooter: true,
        breadcrumbName: '退货进度'
      }
    },
    {
      path: '/personal/order/barter',
      name: 'PersonalOrderBarter',
      component: PersonalOrderBarter,
      meta: {
        requireAuth: true,
        showPageHeader: false,
        showPageFooter: true
      }
    },
    {
      path: '/personal/bill/repay',
      name: 'PersonalBillRepay',
      component: PersonalBillRepay,
      meta: {
        showPageHeader: false,
        showPageFooter: true
      }
    },
    // {
    //   path: '/personal/identity/:type',
    //   name: 'PersonalIdentityAuthentication',
    //   component: PersonalIdentityAuthentication,
    //   props: true,
    //   meta: {
    //     requireAuth: true,
    //     showPageHeader: false,
    //     showPageFooter: true
    //   }
    // },
    {
      path: '/personal/edit',
      name: 'PersonnalIdentityEdit',
      component: PersonalIdentityEdit,
      props: true,
      meta: {
        requireAuth: true,
        showPageHeader: false,
        showPageFooter: true
      },
      children: [
        {
          path: 'identity/:type',
          name: 'PersonalIdentityIdentity',
          component: PersonalIdentityIdentity,
          meta: {
            requireAuth: true,
            showPageHeader: false,
            showPageFooter: true
          }
        },
        /* {
          path: 'student/:type',
          name: 'PersonalIdentityStudent',
          component: PersonalIdentityStudent,
          meta: {
            requireAuth: true,
            showPageHeader: false,
            showPageFooter: true
          }
        }, */
        {
          path: 'contacts/:type',
          name: 'PersonalIdentityContacts',
          component: PersonalIdentityContacts,
          meta: {
            requireAuth: true,
            showPageHeader: false,
            showPageFooter: true
          }
        },
        {
          path: 'success',
          name: 'PersonalIdentitySuccess',
          component: PersonalIdentitySuccess,
          meta: {
            requireAuth: true,
            showPageHeader: false,
            showPageFooter: true
          }
        }
      ]
    },
    {
      path: '/personal/quota',
      name: 'PersonalQuota',
      component: PersonalQuota,
      meta: {
        showPageHeader: false,
        showPageFooter: true
      }
    },
    {
      path: '/buy',
      name: 'buy',
      component: Buy,
      meta: {
        requireAuth: true,
        showPageHeader: false,
        showPageFooter: true
      }
    },
    {
      path: '/buy/protocol',
      name: 'BuyConsentProtocol',
      component: BuyConsentProtocol,
      meta: {
        requireAuth: false,
        showPageHeader: false,
        showPageFooter: false
      }
    },
    {
      path: '/search',
      name: 'Search',
      component: Search,
      meta: {
        showPageHeader: true,
        showPageFooter: true
      }
    },
    {
      path: '/help',
      name: 'Help',
      component: Help,
      meta: {
        showPageHeader: false,
        showPageFooter: true
      }
    },
    {
      path: '/act',
      name: 'Activity',
      component: Activity,
      children: [
        {
          path: 'whiteday',
          name: 'Whiteday',
          component: Whiteday
        }
      ]
    },
    {
      path: '*',
      name: 'NotFound',
      component: NotFound,
      meta: {
        showPageHeader: true,
        showPageFooter: true
      }
    }
  ]
})
